<template>
	<view class="service-page">
		<view class="swiper-box" v-if="bannerConfig.isHidden == 1">
			<view class="swiper-bg"></view>
			<u-swiper :list="bannerList" name="url" :effect3d="true" circular :autoplay="true" border-radius="10" :indicator="false" bg-color="" mode="none" height="318" :interval="bannerConfig.rotationTime"></u-swiper>
		</view>
		<view class="floor-box" v-for="(item,index) in contentList" :key="item.id">
			<view class="floor-title-box">
				<view class="title-box">{{item.iconName}}</view>
				<view class="jump-box" @tap="gotoContentList(item.iconName, item.iconId, item.iconType)">
					<text class="text">全部</text>
					<u-icon name="arrow-right" color="#888888" size="22"></u-icon>
				</view>
			</view>
			<view class="floor-list">
				<block v-for="child in item.partyContentList">
					<news-item :item="child" @tap="gotoDetail(child, item.iconType)" :key="child.id"></news-item>
				</block>
				<block v-for="child in item.communityContentList">
					<news-item :item="child" @tap="gotoDetail(child, item.iconType)" :key="child.id"></news-item>
				</block>
			</view>
			<u-gap height="14" bgColor="#f5f5f5" v-if="index < (contentList.length-1)"></u-gap>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bannerConfig: {
					rotationTime: 3000,
					isHidden: 1 // 1显示 2隐藏
				},
				bannerList: [],
				iconList: [],
				noticeList: [],
				contentList: []
			};
		},
		methods: {
			gotoContentList(title, id, iconType) {
				let url = `/pages/party-sub/content-list/content-list?title=${title}&id=${id}`
				if(iconType == 2){
					url = `/pages/home-sub/news-content-list/news-content-list?title=${title}&id=${id}`
				}
				uni.navigateTo({
					url: url
				})
			},
			
			gotoDetail(item, iconType) {
				let url = `/pages/party-sub/content-detail/content-detail?id=${item.id}`
				if(iconType == 2){
					url = `/pages/home-sub/news-content-detail/news-content-detail?id=${item.id}`
				}
				uni.navigateTo({
					url: url
				})
			},
			init() {
				this.searchBannerList();
				this.getContentList();
				setTimeout(() => {
					uni.stopPullDownRefresh();
				}, 1200)
			},
			// 获取轮播图
			searchBannerList() {
				uni.$u.http.post('app/service-banner/getOne').then(res => {
					let data = res.data;
					this.bannerList = [];
					this.bannerConfig = {
						rotationTime: data.rotationTime * 1000,
						isHidden: data.isHidden // 1显示 2隐藏
					}
			
					for (let i = 1; i <= 6; i++) {
						if (data['pic' + i]) {
							this.bannerList.push({
								url: data['pic' + i]
							})
						}
					}
			
				}).catch(err => {
			
				})
			},
			getContentList() {
				uni.$u.http.post('app/index-icon-flow/getIconFlowContent').then(res => {
					let data = res.list;
					this.contentList = data;

				}).catch(err => {

				})
			}
		},
		onLoad() {
			this.init();
		},
		onPullDownRefresh(){
			this.init();
		}
	}
</script>

<style lang="scss">
	
</style>
